/**
 * 
 */
package br.com.athenas.servico.arq;

import org.hibernate.FlushMode;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate4.SessionFactoryUtils;
import org.springframework.orm.hibernate4.SessionHolder;
import org.springframework.transaction.support.TransactionSynchronizationManager;

import br.com.gadje.arquitetura.util.SpringUtils;

/**
 * @author Joilson-Abrantes
 *
 */
public class GerenciandorBeans {
	
	
	public synchronized static void iniciadoSessionFactory(){
		SessionFactory sessionFactory = (SessionFactory) SpringUtils.getBean("sessionFactory");
		Session session = SessionFactoryUtils.openSession(sessionFactory);
		session.setFlushMode(FlushMode.MANUAL);
		TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session));
	}

}
